package com.pcitc.app.model;

import com.pcitc.app.model.BaseObject;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="TBL_ROLE",schema="XZGD")
public class TblRole extends BaseObject implements Serializable {
    private Long roleid;
    private String rolename;
    private String description;
    private Set<TblRoleMenu> tblRoleMenus = new HashSet<TblRoleMenu>(0);
    private Set<TblUserRole> tblUserRoles = new HashSet<TblUserRole>(0);

    @Id  @GeneratedValue(strategy = GenerationType.AUTO)    
    public Long getRoleid() {
        return this.roleid;
    }
    
    public void setRoleid(Long roleid) {
        this.roleid = roleid;
    }
    
    @Column(name="ROLENAME", length=256)
    public String getRolename() {
        return this.rolename;
    }
    
    public void setRolename(String rolename) {
        this.rolename = rolename;
    }
    
    @Column(name="DESCRIPTION", length=256)
    public String getDescription() {
        return this.description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tblRole")
    public Set<TblRoleMenu> getTblRoleMenus() {
        return this.tblRoleMenus;
    }
    
    public void setTblRoleMenus(Set<TblRoleMenu> tblRoleMenus) {
        this.tblRoleMenus = tblRoleMenus;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tblRole")
    public Set<TblUserRole> getTblUserRoles() {
        return this.tblUserRoles;
    }
    
    public void setTblUserRoles(Set<TblUserRole> tblUserRoles) {
        this.tblUserRoles = tblUserRoles;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TblRole pojo = (TblRole) o;

        if (rolename != null ? !rolename.equals(pojo.rolename) : pojo.rolename != null) return false;
        if (description != null ? !description.equals(pojo.description) : pojo.description != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (rolename != null ? rolename.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("roleid").append("='").append(getRoleid()).append("', ");
        sb.append("rolename").append("='").append(getRolename()).append("', ");
        sb.append("description").append("='").append(getDescription()).append("', ");
        
        
        sb.append("]");
      
        return sb.toString();
    }

}
